import React, { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';

// 相对路径
import { findFilmsPage } from '@/api/MaiZuo';

export default function NowPlaying(props) {
  const [list, setList] = useState([]);
  const navigate = useNavigate();

  useEffect(() => {
    findFilmsPage().then((res) => setList(res.films));
    return () => {};
  }, []);
  console.log('NowPlaying', props);
  return (
    <div>
      <ul>
        {list.map((item) => {
          return (
            <li
              key={item.filmId}
              onClick={() => navigate(`/film/detail/${item.filmId}`)}
            >
              {item.name}
            </li>
          );
        })}
      </ul>
    </div>
  );
}
